/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package comparator;

import halali.CSFDTitle;
import halali.ShowTitle;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import moviedownloader5.DataSourceProvider;

/**
 *
 * @author Patrik
 */
public class Shows {

    private final DataSource ds;
    private final Connection conn;

    private final List<ShowTitle> shows = new ArrayList<>(400000);
    private ResultSet shows_result;

    public Shows() {
        this.ds = DataSourceProvider.getDataSource();
        try {
            conn = ds.getConnection();
            conn.setAutoCommit(true);
        } catch (SQLException ex) {
            throw new IllegalArgumentException(ex);
        }

        try {
            Statement show_statement = conn.createStatement();
            this.shows_result = show_statement.executeQuery("select * from show");

            while (shows_result.next()) {
                ShowTitle show = new ShowTitle(shows_result.getString("show_name"),shows_result.getInt("show_id"));
                this.shows.add(show);
            }
        } catch (SQLException ex) {

        }
        
      /*  for (Show show : this.shows) {
            System.out.println(show.getId() + " " + show.getName());
        }*/
    }
    
    

   /* public List<Show> getShows() {
        return this.shows;
    }*/

  
    
    
    
    
    
    /*public Show getShow(int index) {
        synchronized (this.shows) {
            return this.shows.get(index);
        }
    }
    
    public int getSize() {
        synchronized (this.shows) {
            return this.shows.size();
        }
    }*/

    public List<ShowTitle> getShows() {
        return shows;
    }

}
